import {getOrderBaseVo} from "@/api/chit/chitListPage";

const chitSubPageMixins = {
  data() {
    return {
      chitId: '',
      chitInfo: null
    }
  },
  methods: {
    getChitInfo() {
      let {chitId} = this
      if (chitId == null || chitId == '') {
        if (this.setFormData !== null && typeof this.setFormData == 'function') {
          this.setFormData(null)
        }
        return
      }
      let owner = this
      this.startLoading('正在加载....')
      getOrderBaseVo({id: chitId}).then(response => {
        owner.chitInfo = response.data
        if (owner.setFormData !== null && typeof owner.setFormData == 'function') {
          owner.setFormData(response.data)
        }
      }).finally(() => {
        owner.endLoading()
      })
    }
  },
  created() {
    this.chitId = this.$route.query?.chitId != null && this.$route.query?.chitId !== '' ? this.$route.query.chitId : null;
    this.getChitInfo()
  }
}

export {chitSubPageMixins}
